package cn.wolfcode.luowowo.redis.util;

import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;

//redis中key和过期时间的设定枚举
@Getter
public enum RedisKeys {
    USER_STRATEGY_THUMBSUPNUM("user_strategy_thumbsupnum",-1L),//用户攻略点赞
    USER_STRATEGY_FAVORNUM("user_strategy_favornum",-1L),//用户攻略收藏
    STRATEGY_STATIS_VO("strategy_statis_vo",-1L),//VO对象
    VERIFY_CODE("verify_code" , 300L),//验证码
    LOGIN_DATE("login_date",1800);//登录信息

    private RedisKeys(String prefix , long time){
        this.prefix=prefix;
        this.time=time;
    }
    private String prefix;//前缀
    private long time;//有效时间单位秒,-1表示不设置

    /**
     * 拼接验证码key的方法
     * @return
     */
    public String join(String... keys){
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(prefix);
        for (String key : keys) {
            stringBuilder.append(":").append(key);
        }
        return stringBuilder.toString();
    }
}
